'''
Created on 2010-12-20

@author: yuyouhai
'''
from util import DB

def pageReduce(url):
    url = url[:url.find('?')]


#Def conert2Attf():
#       Attrs = []
#        Linesize = length of first session
#      Tmpline = [?, line size]
#      for each session:
#              Tmpline = [line size ?]
#             For each item in session:
#                    if index = Attrs.find(itemid) == -1:
#                        attrs.append(itemid)
#                        Tmpline.append(1)
#                    Else:
#                         Tmpline[index] = 1
#            
#              Linesize = Len(Attrs)
#          
#        For each line produced above:


def convert2Attf():
    cur = DB.getCur()

    
    cur.execute("select max(c) from (select count(*) \
                as c from simplesession group by sess_key) as b");
    
    lsize= cur.fetchone()[0]
    
    print "linesize:"+str(lsize)
    count = cur.execute("select * from simplesession order by sess_key")
    
    attrs=[]
    tmpline = ['?']*lsize
    
    for i in range(2):
        line = cur.fetchone()
        print line[0]
        print line[1]
        print line[2]
        print line[3]
        print line[4]

    
    

if __name__ == "__main__":
    convert2Attf();